<?php
/**
 * @version		$Id: banners.php 18828 2010-09-10 11:35:07Z infograf768 $
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * @package		Joomla.Administrator
 * @subpackage	com_banners
 * @since		1.6
 */
class skknHelper
{
	/**
	 * Configure the Linkbar.
	 *
	 * @param	string	The name of the active view.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public static function addSubmenu($vName)
	{
		$type = JRequest::getVar('type');
		
		JSubMenuHelper::addEntry(
			JText::_('Files'),
			'index.php?option=com_skkn',
			( $vName == 'texts' || $vName == '' && !isset($type))
		);
		
		JSubMenuHelper::addEntry(
			JText::_('Categories'),
			'index.php?option=com_categories&extension=com_skkn',
			$vName == 'categories'
		);
		if ($vName=='categories') {
			JToolBarHelper::title(
				JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE',JText::_('com_banners')),
				'banners-categories');
		}
		
		$session = JFactory::getSession();

		if(!$type)
			$type = $session->get('com_skkn.document_type');	
		
		JSubMenuHelper::addEntry(
			JText::_('Levels'),
			'index.php?option=com_skkn&view=infos&type=level',
			( $vName == 'infos' && $type == 'level')
		);
		
		JSubMenuHelper::addEntry(
			JText::_('Subjects'),
			'index.php?option=com_skkn&view=infos&type=subject',
			( $vName == 'infos' && $type == 'subject')
		);
	}

	/**
	 * Gets a list of the actions that can be performed.
	 *
	 * @param	int		The category ID.
	 *
	 * @return	JObject
	 * @since	1.6
	 */
	public static function getActions($categoryId = 0)
	{
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($categoryId)) {
			$assetName = 'com_banners';
		} else {
			$assetName = 'com_banners.category.'.(int) $categoryId;
		}

		$actions = array(
			'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete'
		);

		foreach ($actions as $action) {
			$result->set($action,	$user->authorise($action, $assetName));
		}

		return $result;
	}
}